package domain

const (
	StatusProcessing = "processing"
	StatusProcessed  = "processed"
)

type Callback struct {
	Id         int64
	Date       string
	Branch     string
	Status     string
	CallbackId string
}

func (c *Callback) SetStatusProcessing() {
	c.Status = StatusProcessing
}

func (c *Callback) SetStatusProcessed() {
	c.Status = StatusProcessed
}

type CollectResult struct {
	Date   string
	Branch string
	Result string
}

type CallbackDTO struct {
	IssueNum string  `json:"issueId"` // 对方要issueId作为参数名
	CVE      string  `json:"CVE"`
	Score    float64 `json:"score"`
	Version  string  `json:"version"`
	Status   string  `json:"status"`
	Abi      string  `json:"abiChange"`
	Software string  `json:"software"`
}

func ToCallbackDTO(data CollectedDataSlice) []CallbackDTO {
	var dto []CallbackDTO

	for _, v := range data {
		t := CallbackDTO{
			IssueNum: v.Issue.Number,
			CVE:      v.CveNum,
			Score:    v.Score,
			Version:  v.Version,
			Status:   v.Issue.Status,
			Abi:      "否",
			Software: v.Issue.Repo,
		}

		dto = append(dto, t)
	}

	return dto
}
